// 8_6.c
#include <stdio.h>
#include <math.h>

double findAvg(int[], int);        /*function prototype*/
double stdDev(int[], int, double); /*function prototype*/

int main()
{
#define NUMELS 10
    int values[NUMELS] = {98, 82, 67, 54, 78, 83, 95, 76, 68, 63};
    double average, stddev;

    average = findAvg(values, NUMELS);        /*call the function*/
    stddev = stdDev(values, NUMELS, average); /*call the function*/

    printf("The average of the numbers is %5.2f\n", average);
    printf("The standard deviation of the numbers is %5.2f\n", stddev);

    return 0;
}

double findAvg(int nums[], int numel)
{
    int i;
    double sumnums = 0.0;

    for (i = 0; i < numel; i++) /*calculate the sum of the grades*/
        sumnums = sumnums + nums[i];
    return (sumnums / numel); /*calculate the sum of the grades*/
}

double stdDev(int nums[], int numel, double av)
{
    int i;
    double sumdevs = 0.0;

    for (i = 0; i < numel; i++)
        sumdevs = sumdevs + pow((nums[i] - av), 2);

    return (sqrt(sumdevs / numel));
}